- Published on
Getting Started with JS, v2 by Kyle Simpson [Types & Coercion]
- Authors
- Name
- Sudhakar J
Getting Started with JavaScript, v2 by Kyle Simpson
Course Materials
Types & Coercion Notes
Converting Types
- The way to convert from one type to another is
coercion
.
Falsy and Truthy
- Falsy
- “”
- 0, -0
- null
- NaN
- false
- undefined
- Truthy
- “foo”
- 23
- { a:1 }
- [1,3]
- true
- function()
- ...
Equality == vs ===
== allows coercion (types different)
=== disallows coercion (types same)
Scope
Scope: where to look for things.
Undefined vs Undeclared - Undefined is a variable that has been declared, but it doesn't have a value. A variable thats never been declared is undeclared.
Immediately Invoked Function Expressions [IIFE]
- wrap the function with a function making it a function expression. and it's called as a value.
Block Scoping
- This scope restricts the variable that is declared inside a specific block, from access by the outside of the block.
Closure
Closure
is when a function remember the variables outside of it, even if you pass that function elsewhere.
this
- this references the execution context for that call, determined by how the function was called.
this.fn